package com.jiedeng.dao;

import com.jiedeng.model.CorpPost;
import com.jiedeng.model.Project;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author 覃远龙
 * @ClassName: IProjectRepository
 * @Description:
 * @date 2017/8/4 9:41
 */
public interface IProjectRepository extends JpaRepository<Project, Long> {

        List<Project> findByStatus(int status);
        List<Project> findByStatusAndChecker(int status,long checker);

        @Query(nativeQuery = true, value = " select tp.* from t_project tp "+
                " inner JOIN ( "+
                " select Project_ID from t_project_corp where Corp_ID = ?1 "+
                " )a on  a.Project_ID = tp.Project_ID ")
        List<Project> findProjectByCorpIdSQL(Long corpId);

        @Query(nativeQuery = true, value = " SELECT " +
                " tp.* " +
                "FROM " +
                " t_project_corp tpc " +
                " LEFT JOIN t_project tp ON tp.Project_ID = tpc.Project_ID " +
                " WHERE " +
                " tpc.Corp_ID IN( ?1 ) " +
                " AND tp.Status = 3 ")
        List<Project> findProjectByCorpIdsSQL(List<Long> corpId);


}
